package com.woniuxy.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.woniuxy.domain.Permission;
import com.woniuxy.mapper.PermissionMapper;
import com.woniuxy.service.PermissionService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author XXX
 * @since 2021-05-12
 */
@Service
public class PermissionServiceImpl extends ServiceImpl<PermissionMapper, Permission> implements PermissionService {
    @Resource
    private PermissionMapper permissionMapper;
    /**
     *@Author 王昊波
     *@Description 根据用户id查询对应的权限
     *@Param [userId]
     *@return java.util.List<com.woniuxy.domain.Permission>
     */
    @Override
    public List<Permission> selectPermissionByUserId(int userId) throws Exception {
        List<Permission> permissions = permissionMapper.queryPermissionByUserId(userId);
        return permissions;
    }
    /**
     *@Author 王昊波
     *@Description 根据角色id查询对应的权限
     *@Param [roleId]
     *@return java.util.List<com.woniuxy.domain.Permission>
     */
    @Override
    public List<Permission> selectPermissionByRoleId(int roleId) throws Exception{
        List<Permission> permissions = permissionMapper.selectPermissionByRoleId(roleId);
        return permissions;
    }
    /**
     *@Author 王昊波
     *@Description 查询所有的权限
     *@Param []
     *@return java.util.List<com.woniuxy.domain.Permission>
     */
    @Override
    public List<Permission> selectAllPermission() throws Exception {
        List<Permission> permissions = permissionMapper.selectAllPermission();
        return permissions;
    }
    /**
     *@Author 王昊波
     *@Description 根据用户id查询所有权限，单列
     *@Param [userId]
     *@return java.util.List<com.woniuxy.domain.Permission>
     */
    @Override
    public List<Permission> selectPermissionByUserIdNo(int userId) throws Exception {
        List<Permission> permissions = permissionMapper.selectPermissionByUserId(userId);
        return permissions;
    }
}
